package com.xdra.hub.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.xdra.hub.api.ConfigurationApi;
import com.xdra.hub.model.SystemConfiguration;
import lombok.SneakyThrows;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/v1")
public class ConfigurationController implements ConfigurationApi {
    @SneakyThrows
    @Override
    public ResponseEntity<SystemConfiguration> getSystemConfiguration() {
        ObjectMapper objectMapper = new ObjectMapper();
        SystemConfiguration example = objectMapper.readValue("""
                {
                    "containers": [
                        {
                            "id": "1",
                            "clusters": [
                                {
                                    "id": "1",
                                    "packs": [
                                        "1",
                                        "2"
                                    ]
                                },
                                {
                                    "id": "2",
                                    "packs": [
                                        "3",
                                        "4"
                                    ]
                                }
                            ]
                        },
                        {
                            "id": "2",
                            "clusters": [
                                {
                                    "id": "3",
                                    "packs": [
                                        "5",
                                        "6"
                                    ]
                                },
                                {
                                    "id": "4",
                                    "packs": [
                                        "7",
                                        "8"
                                    ]
                                }
                            ]
                        }
                    ],
                    "packType": "pack52"
                }
                """, SystemConfiguration.class);
        return ResponseEntity.ok(example);
    }
}
